package com.alpesressources.comexpert.bo.adapter;

import java.lang.reflect.Type;

import com.alpesressources.comexpert.bo.response.ErrorResponse;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

public class ErrorResponseAdapter implements JsonSerializer<ErrorResponse> {

	@Override
	public JsonElement serialize(ErrorResponse src, Type typeOfSrc,
			JsonSerializationContext context) {

		JsonObject jsonObject = new JsonObject();

		jsonObject.add("errorCode", new JsonPrimitive(src.getErrorCode()
				.getCode()));
		jsonObject.add("message", new JsonPrimitive(src.getMessage()));
		return jsonObject;
	}
}
